﻿using ConfExpert.Utility;
using DevExpress.Utils;
using DevExpress.XtraGrid.Views.Grid;
using DevTeam;

using System;
using System.Drawing;

namespace ConfExpert.Forms.Depo
{
    public partial class AksesuarHareketGC : XPopupForm
    {
        int AksesuarId;
        object StartDate, FinishDate;
        
        public AksesuarHareketGC()
        {
            InitializeComponent();
        }
        public AksesuarHareketGC(int _AksesuarId, object _StartDate, object _FinishDate)
            : this()
        {
            AksesuarId = _AksesuarId;
            StartDate = _StartDate;
            FinishDate = _FinishDate;
        }

        private void AksesuarHareketGC_Load(object sender, EventArgs e)
        {
            txtInfo.Caption = AppSession.Lookups.V_Aksesuar.FindByAksesuarId(AksesuarId).StokKod;

            gvHareket.Init("GetAksesuarHareketById", AksesuarId, StartDate, FinishDate);

            gvHareket.SetCaptions("CariId:GeldigiYer");
            gvHareket.MakeColumnInvisible("AksesuarHareketId");
            gvHareket.MakeReadOnly();

            gvHareket.FormatAsNumber(0, "GelenAdet", "CikanAdet");
            gvHareket.FormatAsDate("GelisTarihi", "CikisTarihi");
            gvHareket.FormatAsNumber(4,"BirimFiyat");

            gvHareket.SetCaptions("CikanIrsaliyeNo:DosyaNo");

            gvHareket.AddSummary("GelenAdet", "CikanAdet");

            gvHareket.Columns["CikisYeri"].ColumnEdit = RI(Rp.Cari);

            gvHareket.RowCellStyle += new RowCellStyleEventHandler(gvHareket_RowCellStyle);

            gvHareket.BestFitColumns();
            gvHareket.Columns["CikanIrsaliyeNo"].Width = 150;
        }

        void gvHareket_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.Column.FieldName.StartsWith("Cik") || e.Column.FieldName == "CustomerId")
                e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
        }
    }
}